App({
    onLaunch: function() {},
    onShow: function() {},
    onHide: function() {
        console.log(getCurrentPages());
    },
    onError: function(e) {
        console.log(e);
    },
    getUrl: function(t) {
        var e = this.globalData.url;
        console.log(e, t), t.setData({
            url: e
        });
        var o = this;
        e || o.util.request({
            url: "entry/wxapp/Url",
            success: function(e) {
                console.log(e), o.globalData.url = e.data, o.getUrl(t);
            }
        });
    },
    setNavigationBarColor: function(t) {
        var e = this.globalData.color;
        console.log(e, t), e && wx.setNavigationBarColor({
            frontColor: "#ffffff",
            backgroundColor: e
        }), t.setData({
            color: e
        });
        var o = this;
        e || o.util.request({
            url: "entry/wxapp/System",
            success: function(e) {
                console.log(e), getApp().xtxx = e.data, o.globalData.color = e.data.color, o.setNavigationBarColor(t);
            }
        });
    },
    getUser: function(a) {
        var s = this;
        wx.login({
            success: function(e) {
                var t = e.code;
                wx.setStorageSync("code", t), wx.getUserInfo({
                    success: function(e) {
                        console.log(e), wx.setStorageSync("user_info", e.userInfo);
                        var o = e.userInfo.nickName, n = e.userInfo.avatarUrl;
                        s.util.request({
                            url: "entry/wxapp/openid",
                            cachetime: "0",
                            data: {
                                code: t
                            },
                            success: function(e) {
                                console.log(e), wx.setStorageSync("key", e.data.session_key), wx.setStorageSync("openid", e.data.openid);
                                var t = e.data.openid;
                                s.util.request({
                                    url: "entry/wxapp/Login",
                                    cachetime: "0",
                                    data: {
                                        openid: t,
                                        img: n,
                                        name: o
                                    },
                                    success: function(e) {
                                        console.log(e), wx.setStorageSync("users", e.data), wx.setStorageSync("uniacid", e.data.uniacid), 
                                        a(e.data);
                                    }
                                });
                            }
                        });
                    },
                    fail: function(e) {
                        wx.getSetting({
                            success: function(e) {
                                0 == e.authSetting["scope.userInfo"] && wx.openSetting({
                                    success: function(e) {
                                        e.authSetting["scope.userInfo"], s.getUser(a);
                                    }
                                });
                            }
                        });
                    }
                });
            }
        });
    },
    getUserInfo: function(t) {
        var o = this, e = this.globalData.userInfo;
        console.log(e), e ? "function" == typeof t && t(e) : wx.login({
            success: function(e) {
                wx.showLoading({
                    title: "正在登录",
                    mask: !0
                }), console.log(e.code), o.util.request({
                    url: "entry/wxapp/Openid",
                    cachetime: "0",
                    data: {
                        code: e.code
                    },
                    header: {
                        "content-type": "application/json"
                    },
                    dataType: "json",
                    success: function(e) {
                        console.log("openid信息", e.data), getApp().getOpenId = e.data.openid, getApp().getSK = e.data.session_key, 
                        o.util.request({
                            url: "entry/wxapp/login",
                            cachetime: "0",
                            data: {
                                openid: e.data.openid
                            },
                            header: {
                                "content-type": "application/json"
                            },
                            dataType: "json",
                            success: function(e) {
                                console.log("用户信息", e), getApp().getuniacid = e.data.uniacid, wx.setStorageSync("users", e.data), 
                                o.globalData.userInfo = e.data, "function" == typeof t && t(o.globalData.userInfo);
                            }
                        });
                    },
                    fail: function(e) {},
                    complete: function(e) {}
                });
            }
        });
    },
    ormatDate: function(e) {
        var t = new Date(1e3 * e);
        return t.getFullYear() + "-" + o(t.getMonth() + 1, 2) + "-" + o(t.getDate(), 2) + " " + o(t.getHours(), 2) + ":" + o(t.getMinutes(), 2) + ":" + o(t.getSeconds(), 2);
        function o(e, t) {
            for (var o = "" + e, n = o.length, a = "", s = t; s-- > n; ) a += "0";
            return a + o;
        }
    },
    ab: function(e) {},
    util: require("we7/resource/js/util.js"),
    siteInfo: require("siteinfo.js"),
    tabBar: {
        color: "#123",
        selectedColor: "#1ba9ba",
        borderStyle: "#1ba9ba",
        backgroundColor: "#fff",
        list: [ {
            pagePath: "/we7/pages/index/index",
            iconPath: "/we7/resource/icon/home.png",
            selectedIconPath: "/we7/resource/icon/homeselect.png",
            text: "首页"
        }, {
            pagePath: "/we7/pages/user/index/index",
            iconPath: "/we7/resource/icon/user.png",
            selectedIconPath: "/we7/resource/icon/userselect.png",
            text: "微擎我的"
        } ]
    },
    globalData: {
        userInfo: null
    }
});